from scapy.all import *
import scapy
import sys, os
from scapy.layers.l2 import Ether

TYPE_NDN = 0x8624


# append

class NDNInterest(Packet):
    name = "NDNInterest"
    fields_desc = [  # value,length
        BitField("TLV_0_Type", 05, 8),  # 05:Interest
        BitField("LV_0_Length", 57, 8),  # remain to be count
        BitField("Name_Type", 07, 8),  # 07:Name
        BitField("Name_Length", 45, 8),  # 4*8=32 that means 8 Character like "beijing0"
        BitField("Component1_Type", 8, 8),
        BitField("Component1_Length", 8, 8),
        BitField("Component1", 0, 64),
        BitField("Component2_Type", 8, 8),
        BitField("Component2_Length", 8, 8),
        BitField("Component2", 0, 64),
        BitField("Component3_Type", 8, 8),
        BitField("Component3_Length", 8, 8),
        BitField("Component3", 0, 64),
        BitField("Componentv_Type", 8, 8),
        BitField("Componentv_Length", 9, 8),
        BitField("Componentv", 0, 72),
        BitField("Componentn_Type", 8, 8),
        BitField("Componentn_Length", 2, 8),
        BitField("Componentn", 0, 16),
        BitField("Nonce_Type", 10, 8),
        BitField("Nonce_Length", 4, 8),
        BitField("Nonce", 9999, 32),
        BitField("InterestLifetime_Type", 12, 8),
        BitField("InterestLifetime_Length", 2, 8),
        BitField("InterestLifetime", 6000, 16),
    ]

    def mysummary(self):
        return self.sprintf("Component1=%Component1%")


# bind_layers(Ether, NDNInterest, type=TYPE_NDN)
